package com.sphd.restaurantsystem.model;


import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.interfaces.VolleyJsonObjectCallBack;
import com.sphd.restaurantsystem.presenter.AddEticketPresenterImpl;

import org.json.JSONException;
import org.json.JSONObject;

/**
* Created by Hu on 2016/12/16
*/

public class AddEticketModelImpl implements AddEticketModel{

    @Override
    public void sendUrl(String url, AddEticketPresenterImpl addEticketPresenter) {
        volleyUtil.setJsonObjectRequest(url, new VolleyJsonObjectCallBack() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    int res=response.getInt("res");
                    addEticketPresenter.recRes(res);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                addEticketPresenter.sendError(error);
            }
        });
    }
}